package com.example.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BeanConfig {
    @Bean     //有一个String类型的对象要交给Spring管理
    public String name(){
        return "caijun";
    }
    @Bean
    public UserInfo userInfo(String name) {
        UserInfo userInfo = new UserInfo();
        userInfo.setId(2);
        userInfo.setName(name);
        userInfo.setAge(34);
        return userInfo;
    }

    /*@Bean
    public UserInfo userInfo2() {
        UserInfo userInfo2 = new UserInfo();
        userInfo2.setId(3);
        userInfo2.setName("lisi");
        userInfo2.setAge(44);
        return userInfo2;
    }*/
}
